package com.qj.yantaishan.controller;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qj.yantaishan.common.annotation.Log;
import com.qj.yantaishan.common.enums.BusinessType;
import com.qj.yantaishan.domain.ProductCategoryFeedback;
import com.qj.yantaishan.service.IProductCategoryFeedbackService;
import com.qj.yantaishan.common.core.controller.BaseController;
import com.qj.yantaishan.common.core.domain.AjaxResult;
import com.qj.yantaishan.common.utils.poi.ExcelUtil;
import com.qj.yantaishan.common.core.page.TableDataInfo;

/**
 * 分类反馈Controller
 * 
 * @author qihe
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/yantaishan/ProductCategoryFeedback")
public class ProductCategoryFeedbackController extends BaseController
{
    private String prefix = "yantaishan/ProductCategoryFeedback";

    @Autowired
    private IProductCategoryFeedbackService productCategoryFeedbackService;

    @RequiresPermissions("yantaishan:feedback:view")
    @GetMapping()
    public String feedback()
    {
        return prefix + "/feedback";
    }

    /**
     * 查询分类反馈列表
     */
    @RequiresPermissions("yantaishan:feedback:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProductCategoryFeedback productCategoryFeedback)
    {
        startPage();
        List<ProductCategoryFeedback> list = productCategoryFeedbackService.selectProductCategoryFeedbackList(productCategoryFeedback);
        return getDataTable(list);
    }

    /**
     * 导出分类反馈列表
     */
    @RequiresPermissions("yantaishan:feedback:export")
    @Log(title = "分类反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProductCategoryFeedback productCategoryFeedback)
    {
        List<ProductCategoryFeedback> list = productCategoryFeedbackService.selectProductCategoryFeedbackList(productCategoryFeedback);
        ExcelUtil<ProductCategoryFeedback> util = new ExcelUtil<ProductCategoryFeedback>(ProductCategoryFeedback.class);
        return util.exportExcel(list, "分类反馈数据");
    }

    /**
     * 新增分类反馈
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存分类反馈
     */
    @RequiresPermissions("yantaishan:feedback:add")
    @Log(title = "分类反馈", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProductCategoryFeedback productCategoryFeedback)
    {
        return toAjax(productCategoryFeedbackService.insertProductCategoryFeedback(productCategoryFeedback));
    }

    /**
     * 修改分类反馈
     */
    @RequiresPermissions("yantaishan:feedback:edit")
    @GetMapping("/edit/{pigcmsId}")
    public String edit(@PathVariable("pigcmsId") Integer pigcmsId, ModelMap mmap)
    {
        ProductCategoryFeedback productCategoryFeedback = productCategoryFeedbackService.selectProductCategoryFeedbackByPigcmsId(pigcmsId);
        mmap.put("productCategoryFeedback", productCategoryFeedback);
        return prefix + "/edit";
    }

    /**
     * 修改保存分类反馈
     */
    @RequiresPermissions("yantaishan:feedback:edit")
    @Log(title = "分类反馈", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProductCategoryFeedback productCategoryFeedback)
    {
        return toAjax(productCategoryFeedbackService.updateProductCategoryFeedback(productCategoryFeedback));
    }

    /**
     * 删除分类反馈
     */
    @RequiresPermissions("yantaishan:feedback:remove")
    @Log(title = "分类反馈", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(productCategoryFeedbackService.deleteProductCategoryFeedbackByPigcmsIds(ids));
    }
}
